{ "definition": { "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", "actions": { "APIKey_DEVICEID": { "inputs": { "variables": [ { "name": "APIKey", "type": "string", "value": "xxx - REPLACE - xxx" } ] }, "runAfter": { "SecretToken": [ "Succeeded" ] }, "type": "InitializeVariable" }, "FileContent": { "inputs": { "variables": [ { "name": "FileContent", "type": "string" } ] }, "runAfter": { "IDList": [ "Succeeded" ] }, "type": "InitializeVariable" }, "For_each": { "actions": { "Create_CSV_table": { "inputs": { "columns": [ { "header": "ID", "value": "@item()?['ID']" }, { "header": "EmployeeCode", "value": "@item()?['EmployeeCode']" }, { "header": "Date", "value": "@formatDateTime(item()?['Date'], 'dd-MM-yyyy')" }, { "header": "JobCode", "value": "@item()?['JobCode']" }, { "header": "OperationCode", "value": "@item()?['OperationCode']" }, { "header": "ActivityCode", "value": "@item()?['ActivityCode']" }, { "header": "TotalTime", "value": "@formatNumber(item()?['TotalTime'],'0,0.00', 'en-us')" } ], "format": "CSV", "from": "@body('HTTP_-_GetJobLedgerEntry')" }, "runAfter": { "For_each_-_GetJobLedgerEntry": [ "Succeeded" ] }, "type": "Table" }, "Create_file_-_JobLedgerEntry.csv": { "inputs": { "body": "@variables('FileContent')", "host": { "connection": { "name": "@parameters('$connections')['onedriveforbusiness']['connectionId']" } }, "method": "post", "path": "/datasets/default/files", "queries": { "folderPath": "/Test", "name": "JobLedgerEntry.csv" } }, "runAfter": { "Set_variable_-_FileContent": [ "Succeeded" ] }, "runtimeConfiguration": { "contentTransfer": { "transferMode": "Chunked" } }, "type": "ApiConnection" }, "For_each_-_GetJobLedgerEntry": { "actions": { "Append_to_string_variable_-_IDList": { "inputs": { "name": "IDList", "value": "@concat(items('For_Each_-_GetJobLedgerEntry')['ID'],',')" }, "runAfter": {}, "type": "AppendToStringVariable" } }, "foreach": "@body('HTTP_-_GetJobLedgerEntry')", "runAfter": { "HTTP_-_GetJobLedgerEntry": [ "Succeeded" ] }, "type": "Foreach" }, "HTTP_-_GetJobLedgerEntry": { "inputs": { "headers": { "API-Key": "@variables('SecretToken')", "DEVICEID": "@variables('APIKey')", "UID": "@items('For_each')['UID']" }, "method": "GET", "queries": { "Filter": "ActivityCode = '310' AND EmployeeCode = '206'", "OrderDirection": "ASC", "OrderFieldName": "Date", "limit": "10", "offset": "0" }, "uri": "@{variables('RESTAPI')}getjobledgerentry" }, "runAfter": {}, "type": "Http" }, "HTTP_-_MarkJobLedgerEntryTransfered": { "inputs": { "headers": { "API-Key": "@variables('SecretToken')", "Content-Type": "application/x-www-form-urlencoded", "DEVICEID": "@variables('APIKey')", "UID": "@items('For_each')['UID']", "accept": "application/json" }, "method": "POST", "queries": { "sIDList": "@variables('IDList')" }, "uri": "@{variables('RESTAPI')}markjobledgerentrytransfered" }, "runAfter": { "Create_file_-_JobLedgerEntry.csv": [ "Succeeded" ] }, "type": "Http" }, "Set_variable_-_FileContent": { "inputs": { "name": "FileContent", "value": "@{replace(replace(body('Create_CSV_table'),',',';'), '.', ',')}" }, "runAfter": { "Create_CSV_table": [ "Succeeded" ] }, "type": "SetVariable" } }, "foreach": "@body('Parse_JSON_-_Get_login_parameters')", "runAfter": { "Parse_JSON_-_Get_login_parameters": [ "Succeeded" ] }, "type": "Foreach" }, "HTTP_-_Login": { "inputs": { "body": "sAPIKey=@{variables('APIKey')}", "headers": { "API-Key": "@variables('SecretToken')", "Content-Type": "application/x-www-form-urlencoded", "accept": "application/json" }, "method": "POST", "uri": "@{variables('RESTAPI')}apilogin" }, "runAfter": { "FileContent": [ "Succeeded" ] }, "type": "Http" }, "IDList": { "inputs": { "variables": [ { "name": "IDList", "type": "string" } ] }, "runAfter": { "RESTAPI": [ "Succeeded" ] }, "type": "InitializeVariable" }, "Parse_JSON_-_Get_login_parameters": { "inputs": { "content": "@body('HTTP_-_Login')", "schema": { "items": { "properties": { "DatabaseVersion": { "type": "string" }, "LanguageCode": { "type": "string" }, "UID": { "type": "string" } }, "required": [ "UID", "LanguageCode", "DatabaseVersion" ], "type": "object" }, "type": "array" } }, "runAfter": { "HTTP_-_Login": [ "Succeeded" ] }, "type": "ParseJson" }, "RESTAPI": { "inputs": { "variables": [ { "name": "RESTAPI", "type": "string", "value": "https://smartapi.smarttid.dk/" } ] }, "runAfter": { "APIKey_DEVICEID": [ "Succeeded" ] }, "type": "InitializeVariable" }, "SecretToken": { "inputs": { "variables": [ { "name": "SecretToken", "type": "string", "value": "xxx - REPLACE - xxx" } ] }, "runAfter": {}, "type": "InitializeVariable" } }, "contentVersion": "1.0.0.0", "outputs": {}, "parameters": { "$connections": { "defaultValue": {}, "type": "Object" } }, "triggers": { "Recurrence": { "evaluatedRecurrence": { "frequency": "Day", "interval": 1, "schedule": { "hours": [ "10", "15" ] }, "startTime": "2021-10-06T00:00:00Z", "timeZone": "Romance Standard Time" }, "recurrence": { "frequency": "Day", "interval": 1, "schedule": { "hours": [ "10", "15" ] }, "startTime": "2021-10-06T00:00:00Z", "timeZone": "Romance Standard Time" }, "type": "Recurrence" } } }, "parameters": { "$connections": { "value": { "onedriveforbusiness": { "connectionId": "xxx - REPLACE - xxx", "connectionName": "onedriveforbusiness-2", "id": "xxx - REPLACE - xxx" } } } } }